﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TARADesktopDoctor
{
	/// <summary>
	/// Interaction logic for AssessmentItem.xaml
	/// </summary>
	public partial class AssessmentItem : UserControl
	{
        public AssessmentItem(tara_wcf.EXE exe)
		{
			this.InitializeComponent();
            lblName.Text = exe.Name;
            lblDescription.Text = exe.Description;
		}

        private void ResetSelectionColors()
        {
            if (this.Parent != null)
            {
                if (this.Parent is StackPanel)
                {
                    StackPanel assessmentPanel = (StackPanel)this.Parent;
                    foreach (UIElement element in assessmentPanel.Children)
                    {
                        if (element is AssessmentItem)
                        {
                            AssessmentItem ai = (AssessmentItem)element;
                            ai.lblName.Foreground = Brushes.Black;
                            ai.lblDescription.Foreground = Brushes.Black;
                            ai.Background = null;
                        }
                    }
                }
            }
        }

        private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ResetSelectionColors();
            this.lblName.Foreground = Brushes.White;
            this.lblDescription.Foreground = Brushes.White;
            this.Background = new SolidColorBrush(Color.FromArgb(255, 47, 113, 204));
        }

        private void btnRun_Click(object sender, RoutedEventArgs e)
        {
            ResetSelectionColors();
            this.lblName.Foreground = Brushes.White;
            this.lblDescription.Foreground = Brushes.White;
            this.Background = new SolidColorBrush(Color.FromArgb(255, 47, 113, 204));
            MainWindow rootWindow = Application.Current.MainWindow as MainWindow;
            rootWindow.frame1.Navigate(new AssessmentROM());
        }
	}
}